﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage/Main.master" AutoEventWireup="true" CodeFile="advertDetail.aspx.cs" Inherits="advert_advertDetail" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headcss" Runat="Server">
<link href="/themes/default/css/layer.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.imgView li{float: left;height: 200px; margin-right: 5px;padding: 5px;width: 105px;}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<fieldset>
<legend>Advert Detail</legend>
<table class="editTable" border="1" cellspacing="1" cellpadding="0" style="width: 100%;">
    <tr>
        <th>
            <font color="red">*</font>广告编码：
        </th>
        <td>
            <input id="AdvertNo" name="AdvertNo" type="text" maxlength="25" style="width: 350px" value="<%=advertise.AdvertNo %>" />
            <font color="red">GA事件标签 命名规范：内容或主题+发布时间</font>
        </td>
        <td style="width: 100px;">
            不能为空!
        </td>
    </tr>
    <tr>
        <th style="width: 100px;">
            <font color="red">*</font>广告名称：
        </th>
        <td style="width: 600px;">
            <input id="AdvertName" name="AdvertName" type="text" maxlength="20" style="width: 350px"
                value="<%=advertise.AdvertName %>" />
        </td>
        <td style="width: 100px;">
            不能为空!
        </td>
    </tr>
    <tr class="SpaceIDBlock">
        <th style="width: 100px;">
            盖世广告：
        </th>
        <td style="width: 600px;">
            <input type="checkbox" id="CompanyCrmID" name="CompanyCrmID" value="-99" checked="checked" />
        </td>
    </tr>
    <tr id="KeyWordBlock" class="KeyWordBlock">
        <th style="width: 100px;">
            <font color="red">*</font>关键词：
        </th>
        <td style="width: 600px;">
            <input id="KeyWords" name="KeyWords" type="text" maxlength="100" value="<%=advertise.KeyWords %>" />
            <span style="color: red">所属广告位属于关键词广告，可在此填写关键词</span>
        </td>
        <td style="width: 100px;">
            不能为空!
        </td>
    </tr>
    <tr>
        <th style="width: 130px;">
            <font color="red">*</font> 广告显示类型：
        </th>
        <td style="width: 600px;">
            <%=DropSourceTypeHtml("AdvertType", advertise.AdvertType.ToString())%>
        </td>
        <td style="width: 100px;">
            不能为空!
        </td>
    </tr>
    <tr>
        <th style="width: 100px;">
            <font color="red">*</font>广告URL地址：
        </th>
        <td style="width: 600px;">
            <input id="Url" name="Url" type="text" maxlength="250" value="<%=advertise.Url %>" /><input type="checkbox" id="urlNull"/>无链接
        </td>
        <td>
            不能为空!
        </td>
    </tr>
    <tr>
        <th style="width: 100px;">
            <font color="red">*</font>广告文字：
        </th>
        <td style="width: 600px;">
            <input id="Text" name="Text" type="text" maxlength="500" value="<%=advertise.Text %>" />
        </td>
        <td style="width: 100px;">
            不能为空!
        </td>
    </tr>
    <tr>
        <th style="width: 100px;">
            <font color="red">*</font>提示信息：
        </th>
        <td style="width: 600px;">
            <input id="Alt" name="Alt" type="text" maxlength="200" value="<%=advertise.Alt %>" />
        </td>
        <td style="width: 100px;">
            不能为空!
        </td>
    </tr>
    <tr class="Pic">
        <th style="width: 100px;">
            文 件：
        </th>
        <td style="width: 600px;">
            <asp:FileUpload ID="FileUpload1" runat="server" onchange="checkfile(this)" />
            <div id="uploadTip">
            </div>
        </td>
    </tr>
    <tr class="Pic">
    <th></th>
    <td>
        <%if (!string.IsNullOrEmpty(advertise.AdvertPath))
            { %>
        <img alt="" src="<%=advertise.viewAdvertPath %>" />
        <%} %>
        </td>
    </tr>
    <tr class="wPic">
        <th style="width: 100px;">
            宽屏广告：
        </th>
        <td style="width: 600px;">
            <asp:FileUpload ID="FileUpload2" runat="server" onchange="checkfile(this)" />  
            <div id="WuploadTip">
            </div>                      
        </td>
    </tr>
    <tr class="wPic">
    <th></th>
    <td>
        <%if (!string.IsNullOrEmpty(advertise.BAdvertPath))
            { %>
        <img alt="" src="<%=advertise.viewBAdvertPath %>" />
        <%} %>
        </td>
    </tr>
    <tr>
        <th>
            <font color="red">*</font>广告描述:
        </th>
        <td>
            <textarea id="Description" name="Description" style="width: 444px; height: 250px"><%=advertise.Description%></textarea>
        </td>
        <td style="width: 100px;">
            不能为空,描述在1000字内!
        </td>
    </tr>
    <tr>
        <th style="width: 130px;">
            <font color="red">*</font>广告有效期：
        </th>
        <td style="width: 600px;">
            <input id="BeginTime" name="BeginTime" type="text" style="width: 150px" value="<%=advertise.BeginTime%>" />
            &nbsp&nbsp<input id="EndTime" name="EndTime" type="text" style="width: 150px" value="<%=advertise.EndTime%>" />
        </td>
        <td style="width: 100px;">
            开始时间不能为空! 结束时间不能为空!
        </td>
    </tr>
    <tr>
        <th style="width: 100px;">
            启 用：
        </th>
        <td style="width: 600px;">
            <%=DropChangeStatusHtml("Status",advertise.Status.ToString())%>
        </td>
    </tr>
</table>
<div style="text-align:center;">
    <input type="submit" onclick="return CheckVal();" value="Approve" />
    &nbsp;&nbsp;
    <input type="button" onclick="window.close();" value="Cancel" />
</div>
<input id="SpaceID" name="SpaceID" value="<%=advertise.SpaceID%>" type="hidden" />
</fieldset>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="footer" Runat="Server">
<script src="/js/common/My97DatePicker/WdatePicker.js" type="text/javascript" defer="defer"></script>
<script type="text/javascript">
        $(document).ready(function() {
            $("#BeginTime").focus(function() { WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' ,maxDate: $("#EndTime").val()}) });
            $("#EndTime").focus(function() { WdatePicker({ dateFmt: 'yyyy-MM-dd HH:mm:ss' ,minDate: $("#BeginTime").val()}) });

            SpaceHeightWidth();

            if ($("#AdvertType").val() == "1" || $("#AdvertType").val() == "4") {
                    $(".wPic").hide();
                    $(".Pic").hide();
                }
            $("#AdvertType").change(function() {
                if ($("#AdvertType").val() == "1" || $("#AdvertType").val() == "4") {
                    $(".wPic").hide();
                    $(".Pic").hide();
                } else {
                    if(<%=space.SizeType %> == 1 && ($("#AdvertType").val() == "2" || $("#AdvertType").val() == "3"|| $("#AdvertType").val() == "5")){
                        $(".wPic").show();
                    }
                    $(".Pic").show();
                }
            });
            if($("#Url").val().length == 0 && "<%=action %>" == "edit"){
                $("#Url").attr("disabled","disabled");
                $("#urlNull").attr("checked","checked")
            }
        });
        function CheckVal() {
            var AdvertNo = $("#AdvertNo").val();
            var AdvertName = $("#AdvertName").val();
            var KeyWords = $("#KeyWords").val();
            var Url = $("#Url").val();
            if(Url.length == 0 && $("#urlNull").attr("checked") != "checked"){
                alert("请填写url");
                return false;
            }
            var Text = $("#Text").val();
            var Alt = $("#Alt").val();
            var Description = $("#Description").val();
            if (Description.length > 1000) {
                alert("描述超过1000字");
                return false;
            }
            var BeginTime = $("#BeginTime").val();
            var EndTime = $("#EndTime").val();
            if (($("#KeyWordBlock").attr("style") == undefined || $("#KeyWordBlock").attr("style").indexOf("none") == -1) && KeyWords.length == 0) {
                alert("填写关键字");
                return false;
            }

            if (AdvertNo.length == 0 || AdvertName.length == 0 || Text.length == 0 || Alt.length == 0
             || Description.length == 0 || BeginTime.length == 0 || EndTime.length == 0) {
                alert("填写完整");
                return false;
            }
            if("<%=action %>" == "add" && ($("#AdvertType").val() == "2" || $("#AdvertType").val() == "3"|| $("#AdvertType").val() == "5")) {    
                if($("#<%=FileUpload1.ClientID%>").val().length == 0){
                    alert("请上传广告！");
                    return false;
                }
                if ($("#<%=FileUpload2.ClientID%>").val().length == 0 && <%=space.SizeType %> == 1) {
                    alert("请上传宽屏广告！");
                    return false;
                }
            }
            return true;
        }
        function checkfile(obj) {

            var path = String(obj.value);
            var ext = path.substring(path.lastIndexOf(".")).toLowerCase();

            if ($("#AdvertType").val() == "2") {

                if (ext != ".jpg" && ext != ".gif" && ext != ".jpeg" && ext != ".png" && ext != ".bmp") {
                    alert("请输入图片格式！");
                    obj.value = "";
                    return false;
                }
            }
            else if ($("#AdvertType").val() == "3") {
                if (ext != ".swf") {
                    alert('请输入Flash格式！');
                    obj.value = "";
                    return false;
                }
            }
            return true;
        }
        
        $("#urlNull").change(function() {
            var haveUrl=$("#urlNull").attr("checked")
            if(haveUrl=="checked"){
                $("#Url").val("");
                $("#Url").attr("disabled","disabled");
            }else{
                 $("#Url").removeAttr("disabled");
            }
        });

        function SpaceHeightWidth() {
            var id = $("#SpaceID").val();
            $.ajax({
                type: "post",
                url: "/handlers/SpaceHWHandler.ashx",
                data: "ID=" + id,
                success: function(msg) {
                    $("#uploadTip").html(msg);
                },
                error: function(e) {
                    $("#uploadTip").html("读取错误");
                }
            });
        }
    </script>
</asp:Content>

